import json
from models import BaseModels
from sqlalchemy import Column, ForeignKey, String, Date, BigInteger, Integer, Text


class Charge (BaseModels):
    __tablename__ = 'charges'
    id = Column(BigInteger, autoincrement=True, primary_key=True, unique=True, nullable=False)
    user_id1 = Column(BigInteger, ForeignKey("users.id"), comment="现场负责人")
    user_id2 = Column(BigInteger, ForeignKey("users.id"), comment="品质负责人")
    user_id3 = Column(BigInteger, ForeignKey("users.id"), comment="工艺设备负责人")

    def __repr__(self):
        return json.dumps({
            "facility_id": self.id,
            "user_id1": self.user_id1,
            "user_id2": self.user_id2,
            "user_id3": self.user_id3
        })

